<script setup>
import {
    Edit,
    Delete
} from '@element-plus/icons-vue'

import { ref } from 'vue'




const queryTime = ref([])



//文章列表数据模型
const historyData = ref([

])


//分页条数据模型
const pageNum = ref(1)//当前页
const total = ref(20)//总条数
const pageSize = ref(15)//每页条数

//当每页条数发生了变化，调用此函数
const onSizeChange = (size) => {
    pageSize.value = size
     historyDataList()
}
//当前页码发生变化，调用此函数
const onCurrentChange = (num) => {
    pageNum.value = num
    historyDataList()
}



import { historyDataListService} from '@/api/historyData.js'



import { Plus } from '@element-plus/icons-vue'
import { QuillEditor } from '@vueup/vue-quill'
import '@vueup/vue-quill/dist/vue-quill.snow.css'







const historyDataList = async () => {

    let params = {
        pageNum: pageNum.value,
        pageSize: pageSize.value,
        timeFrom: queryTime.value ? queryTime.value[0] : null,
        timeEnd: queryTime.value ? queryTime.value[1] : null,
    }
    let result = await historyDataListService(params);
    //渲染视图
    total.value = result.data.total;
    historyData.value = result.data.records;


}


historyDataList();

</script>
<template>
    <el-card class="page-container">
        <template #header>
            <div class="header">
                <span>历史数据</span>
            </div>
        </template>
        <!-- 搜索表单 -->
        <el-form inline>
            <el-form-item label="时间：">
                <el-date-picker v-model="queryTime"  type="daterange" align="right" unlink-panels range-separator="至"
                    start-placeholder="开始日期" end-placeholder="结束日期" value-format="YYYY-MM-DD">
                </el-date-picker>
            </el-form-item>

            <el-form-item>
                <el-button type="primary" @click="historyDataList">搜索</el-button>
            </el-form-item>
        </el-form>
        <!-- 文章列表 -->
        <el-table :data="historyData" border style="width: 100%">
            <el-table-column label="日期" width="200" prop="dayTime"></el-table-column>
            <el-table-column label="总用户" prop="totalUserCount"></el-table-column>
            <el-table-column label="当日活跃总用户" prop="dailyActiveUserCount"> </el-table-column>
            <el-table-column label="当日新增用户" prop="dailyAddUserCount"></el-table-column>
            <el-table-column label="次日留存" prop="nextDayLastUserCount"> </el-table-column>
            <el-table-column label="7日留存" prop="sevenDayLastUserCount"></el-table-column>
            <el-table-column label="当日收入（元）" prop="dailyIncome"></el-table-column>
            <el-table-column label="渠道收入-360（元）" prop="incomeFromThreeSixty"></el-table-column>
            <el-table-column label="渠道收入-掌育（元）" prop="incomeFromZy"></el-table-column>
            <el-table-column label="渠道收入-三基同创（元）" prop="incomeFromSjtc"></el-table-column>
            <el-table-column label="渠道收入-华为（元）" prop="incomeFromHw"></el-table-column>
            <el-table-column label="渠道收入-小米（元）" prop="incomeFromXm"></el-table-column>
          <el-table-column label="当日退款（元）" prop="dailyRefund"></el-table-column>
          <el-table-column label="渠道退款-360（元）" prop="refundFromThreeSixty"></el-table-column>
          <el-table-column label="渠道退款-掌育（元）" prop="refundFromZy"></el-table-column>
          <el-table-column label="渠道退款-三基同创（元）" prop="refundFromSjtc"></el-table-column>
          <el-table-column label="渠道退款-华为（元）" prop="refundFromHw"></el-table-column>
          <el-table-column label="渠道退款-小米（元）" prop="refundFromXm"></el-table-column>
            <template #empty>
                <el-empty description="没有数据" />
            </template>
        </el-table>
        <!-- 分页条 -->
        <el-pagination v-model:current-page="pageNum" v-model:page-size="pageSize" :page-sizes="[3, 5, 10, 15]"
            layout="jumper, total, sizes, prev, pager, next" background :total="total" @size-change="onSizeChange"
            @current-change="onCurrentChange" style="margin-top: 20px; justify-content: flex-end" />




    </el-card>
</template>
<style lang="scss" scoped>
.page-container {
    min-height: 100%;
    box-sizing: border-box;

    .header {
        display: flex;
        align-items: center;
        justify-content: space-between;
    }
}


/* 抽屉样式 */
.avatar-uploader {
    :deep() {
        .avatar {
            width: 178px;
            height: 178px;
            display: block;
        }

        .el-upload {
            border: 1px dashed var(--el-border-color);
            border-radius: 6px;
            cursor: pointer;
            position: relative;
            overflow: hidden;
            transition: var(--el-transition-duration-fast);
        }

        .el-upload:hover {
            border-color: var(--el-color-primary);
        }

        .el-icon.avatar-uploader-icon {
            font-size: 28px;
            color: #8c939d;
            width: 178px;
            height: 178px;
            text-align: center;
        }
    }
}

.editor {
    width: 100%;

    :deep(.ql-editor) {
        min-height: 200px;
    }
}
</style>